<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${sectionName}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" href="/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="/css/Community.css"/>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script>
    <script>
        L2Dwidget.init({
            "model": {
                jsonPath: "https://unpkg.com/live2d-widget-model-hijiki@1.0.5/assets/hijiki.model.json",
                "scale": 1
            },
            "display": {
                "position": "right",
                "width": 100,
                "height": 200,
                "hOffset": 0,
                "vOffset": -20
            },
            "mobile": {
                "show": true,
                "scale": 0.5
            },
            "react": {
                "opacityDefault": 1,
                "opacityOnHover": 1
            }
        });
    </script>
    <script type="text/javascript">
        var a_idx = 0;
        jQuery(document).ready(function ($) {
            $("body").click(function (e) {
                var a = new Array("佐田", "闪电五连鞭", "🐎老师，发生甚么事了", "给我发了几张截图"
                    , "耗子尾汁", "不要搞，窝里斗", "小聪明", "二百斤的嘤国大理石也折不动我的手指头",
                    "左刺拳", "左正蹬", "右鞭腿", "化劲", "接化发", "婷婷");
                var $i = $("<span/>").text(a[a_idx]);
                a_idx = parseInt(Math.random() * (13 - 0 + 1), 10);
                var x = e.pageX,
                    y = e.pageY;
                $i.css({
                    "z-index": 9999,
                    "top": y - 20,
                    "left": x,
                    "position": "absolute",
                    "font-weight": "bold",
                    "color": "#5bc0de"
                });
                $("body").append($i);
                $i.animate({
                        "top": y - 180,
                        "opacity": 0
                    },
                    1500,
                    function () {
                        $i.remove();
                    });
            });
        });
    </script>
</head>
<body>
<!-- 导航栏布局设计 -->
<div th:insert="~{navigation :: nav}"></div>
<!-- 首页问题列表问题设计 -->
<div class="container-fluid main profile">
    <div class="row">

        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <h2><span class="glyphicon glyphicon-list-alt" aria-hidden="true" th:text="${sectionName}"></span></h2>
            <hr/>

            <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12" th:if="${section == 'questions'}">
                <div class="media" th:each="question :${pagination.data}">
                    <div class="media-left">
                        <a th:href="@{'/question/'+${question.id}}">
                            <!--th:src="${question.user.avatarUrl}"-->
                            <img class="media-object img-rounded" th:src="${question.user.avatarUrl}" th:alt="图片获取失败">
                        </a>
                    </div>
                    <div class="media-body">
                        <h4 class="media-heading">
                            <a th:href="@{'/question/'+${question.id}}" th:text="${question.title}"></a>
                        </h4>
                        <span class="text-desc"><span th:text="${question.commentCount}"></span>个回复 ·
                        <span th:text="${question.viewCount}"></span>次浏览 · <span
                                    th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span></span>
                        <a class="community-menu indent" th:href="@{'/publish/'+${question.id}}"
                           th:if="${session.user != null && session.user.id == question.creator} "
                           style="text-decoration:none">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true">编辑</span>

                        </a>
                        <a class="community-menu indent" th:href="@{'/profile/question/delete/'+${question.id}}"
                           th:if="${session.user != null && session.user.id == question.creator} "
                           style="text-decoration:none">
                            <span class="glyphicon glyphicon-trash" aria-hidden="true">删除</span>
                            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        </a>
                    </div>
                </div>
                <!-- 这部分是对分页功能的设计-->
            </div>

            <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12" th:if="${section == 'replies'}">
                <div class="media" th:each="notification :${pagination.data}">

                    <div class="media-body">
                        <h5 class="media-heading">
                            <span th:text="${notification.notifierName+' '+notification.typeName+' '}"></span>
                            <a th:href="@{'/notification/'+${notification.id}}"
                               th:text="${notification.outerTitle}"></a>
                            <span class="label label-warning" th:if="${notification.status == 0}">未读</span>
                        </h5>
                    </div>
                </div>
            </div>
            <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
                <nav aria-label="Page navigation">
                    <ul class="pagination">
                        <!--设计返回首页按钮-->
                        <li th:if="${pagination.showFirstPage}">
                            <a th:href="@{'/profile/'+${section}(page=${1})}"
                               aria-label="FirstPage">
                                <span aria-hidden="true">&lt;&lt;</span>
                            </a>
                        </li>
                        <!--                    设计向前一页按钮-->
                        <li th:if="${pagination.showPrevious}">
                            <a th:href="@{'/profile/'+${section}(page=${pagination.currentPage -1})}"
                               aria-label="Previous">
                                <span aria-hidden="true">&lt;</span>
                            </a>
                        </li>
                        <!--设计分页展示内容，并将选中的分页高亮显示-->
                        <li th:each="page :${pagination.pages}"
                            th:class="${pagination.currentPage == page}? 'active':''">
                            <a th:href="@{'/profile/'+${section}(page=${page})}" th:text="${page}">
                            </a>
                        </li>
                        <!--                显示向后一页按钮-->
                        <li th:if="${pagination.showNext}">
                            <a th:href="@{'/profile/'+${section}(page=${pagination.currentPage +1})}"
                               aria-label="NextPage">
                                <span aria-hidden="true">&gt;</span>
                            </a>
                        </li>

                        <!--                    显示转到最后一页功能-->
                        <li th:if="${pagination.showEndPage}">
                            <a th:href="@{'/profile/'+${section}(page=${pagination.totalPage})}" aria-label="EndPage">
                                <span aria-hidden="true">&gt;&gt;</span>
                            </a>
                        </li>
                        <!-- 最后，分页栏还对不正常的分页数如-1，或页面数远远大于已有的页码数，进行了纠错处理。-->
                    </ul>
                </nav>
            </div>
        </div>

        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
            <div class="list-group section">
                <a href="/profile/questions"
                   th:class="${section == 'questions'}? 'active list-group-item':'list-group-item'">我的问题</a>
                <a href="/profile/replies"
                   th:class="${section == 'replies'}? 'active list-group-item ':'list-group-item'">
                    最新回复
                    <span class="badge" th:if="${session.unreadCount != 0}" th:text="${session.unreadCount}"></span>
                </a>
            </div>
        </div>

    </div>
</div>
</body>
</html>